﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TinyCinema.Data;
using System.Windows.Input;
using System.Windows;
using System.Windows.Controls;
using System.Collections.ObjectModel;
using TinyCinema.Bussiness;

namespace TinyCinema.Bussiness.AdminPanel
{
    public class Backup : DependencyObject
    {
        public static Messenger Messenger = new Messenger();
        public static void BackupDatabase(string s)
        {
            try { Data.Execution.BackupDatabase(s); }
            catch(System.IO.IOException) 
            {
                Messenger.Send(new Message.PermissionDenied());
            }
        }
        public static void RestoreDatabase(string s)
        {
            Messenger.Send(new Message.Restoring());
            try { Data.Execution.RestoreDatabase(s); }
            catch (System.IO.FileNotFoundException)
            {
                Messenger.Send(new Message.RestorFailed());
                Messenger.Send(new Message.FileNotFound());
                return;
            }
            catch(Exception)
            {
                Messenger.Send(new Message.RestorFailed());
                Messenger.Send(new Message.InputFileIsNotCorrect());
                return;
            }
            Messenger.Send(new Message.Restored());
        }
    }
}
